//var base = 'http://47.52.68.89:5000/';
var base = 'http://120.77.255.18:8011/api/';
//var base = 'http://www.51weidai.com/api/';
$(function() {
	$('.close-icon').on('tap', function() {
		$(this).siblings('input').val('');
		$(this).hide();
		$('.btn').removeClass('active');
	});

	$('input').on('change', function() {
		var value = $(this).val();
		if(value) {
			$(this).siblings('.close-icon').show();
			$('.btn').addClass('active');
		} else {
			$(this).siblings('.close-icon').hide();
			$('.btn').removeClass('active');
		}
	});

	$('.unsee-icon').on('tap', function() {
		var that = $(this);
		if(!(that.hasClass('see'))) {
			that.addClass('see');
			that.siblings('input').attr('type', 'text');
		} else {
			that.removeClass('see');
			that.siblings('input').attr('type', 'password');
		}
	});
});

tab('.m-message .tabs .tab', '#item', 'cur', 2);
tab('.m-message .child-tabs .tab', '#child-item', 'cur', 6);
tab('.m-projectdetail .borrow-tabs .tab', '#step', 'active', 3);

function tab(moveobj, obj, _class, num) {
	$(moveobj).on('tap', function() {
		var that = $(this),
			id = parseInt($(this).attr('data-id'));
		if(!(that.hasClass(_class))) {
			that.addClass(_class).siblings('.tab').removeClass(_class);

			for(var i = 1; i <= num; i++) {
				if(i == id) {
					$(obj + i).removeClass('hide');
				} else {
					$(obj + i).addClass('hide');
				}
			}
		}
	});
}

function banklogo(text) {
	switch(text) {
		case "CIB":
			return "../images/bank/cib.png";
		case "BOC":
			return "../images/bank/boc.png";
		case "BOCOM":
			return "../images/bank/bocom.png";
		case "CMBC":
			return "../images/bank/cmbc.png";
		case "PINGAN":
			return "../images/bank/pingan.png";
		case "CCB":
			return "../images/bank/ccb.png";
		case "ABC":
			return "../images/bank/abc.png";
		case "ICBC":
			return "../images/bank/icbc.png";
		case "SDB":
			return "../images/bank/sdb.png";
		case "SPDB":
			return "../images/bank/spdb.png";
		case "PSBC":
			return "../images/bank/psbc.png";
		case "CMB":
			return "../images/bank/cmb.png";
		case "CEB":
			return "../images/bank/ceb.png";
		case "CITIC":
			return "../images/bank/citic.png";
		case "GDB":
			return "../images/bank/cgb.png";
		case "BOS":
			return "../images/bank/bos.png";
		case "CBHB":
			return "../images/bank/cbhb.png";
		case "HFB":
			return "../images/bank/hfb.png";
		case "HXB":
			return "../images/bank/hxb.png";
		default:
			return string.Empty;
	}
}

function sign(md5) {
	var timestamp = new Date().getTime();
	var sign = md5 ? md5(md5(timestamp).toUpperCase()).toUpperCase() : '';
	return {
		'timestamp': timestamp,
		'sign': sign
	};
}